package com.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.entity.Preorder;
import com.entity.PreorderPlus;
import com.mapper.PreorderMapper;
import com.service.PreorderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class PreorderServiceImpl extends ServiceImpl<PreorderMapper, Preorder> implements PreorderService {
    @Autowired
    PreorderMapper preorderMapper;


//    @Override
//    public String toString()
//    {
//        preorderMapper.selectPage()
//    }
//    查询所有
    @Override
    public List<PreorderPlus> FindByPages()
    {
        return preorderMapper.preorderInfo();
    }
//新增
    @Override
    public int savePreorder(Preorder preorder) {
        System.out.println("进入savePreorder");
        System.out.println(preorder.getpState()+"：状态");
        System.out.println(preorder.getpDate()+"：时间");
        Preorder preorder1 = new Preorder();
//将数据添加到这个集合
        preorder1.setpDate(preorder.getpDate());
        preorder1.setpState(preorder.getpState());
        preorder1.setgId(preorder.getgId());
        preorder1.settId(preorder.gettId());
        preorder1.setuId(preorder.getuId());
         return preorderMapper.insert(preorder1);
    }
    @Override
    public int delPreorder(Preorder preorder)
    {
        Integer gid = preorder.getgId();
        Integer tid = preorder.gettId();
        String date = preorder.getpDate();
        System.out.println("gid :"+gid+" "+"tid :"+tid+" "+"p_date :"+date);
        System.out.println();
        return preorderMapper.delPreorder(gid,tid,date);
    }

    @Override
    public int updatePreorder(Preorder preorder) {
        System.out.println(preorder.toString());
        int gid = preorder.getgId();
        int tid = preorder.gettId();
        int pstate = preorder.getpState();
        String date = preorder.getpDate();
        return preorderMapper.updatePreorder(gid,tid,date,pstate);
    }
}
